//
//  main.m
//  gh
//
//  Created by mac on 16-5-10.
//  Copyright (c) 2016年 oyzh. All rights reserved.
//

//
//  main.m
//  sdf
//
//  Created by mac on 16-5-10.
//  Copyright (c) 2016年 oyzh. All rights reserved.
//

//
//  main.m
//  main
//
//  Created by mac on 16-5-10.
//  Copyright (c) 2016年 oyzh. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    
    @autoreleasepool {
        
        // insert code here...
        NSLog(@"Hello, World!");
        NSString *path=@"/Users/mac/Desktop/0001.vcf";
        NSError *err;
        NSString *str=[[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
        NSArray *arr=[str componentsSeparatedByString:@"\n"];
        if (err!=nil) {
            NSLog(@"sasd");
        }
        NSLog(@"%@",str);
        for(NSString *line in arr){
            if ([line hasPrefix:@"TEL"]) {
                NSLog(@"找到一条电话记录");
                NSArray *a=[line componentsSeparatedByString:@";"];
                NSString *last=[a lastObject];
                last=[last substringFromIndex:5];
                NSLog(@"a:%@",last);
            }
            if ([line hasPrefix:@"FN"]) {
                NSLog(@"找到一条FN 也就是姓名");
                NSArray *name=[ line componentsSeparatedByString:@":"];
                NSString *names=[name lastObject];
                names=[names stringByReplacingOccurrencesOfString:@"=" withString:@"%"];
                names=names.stringByRemovingPercentEncoding;
                NSLog(@"name%@",names);
                
            }
        }
    }
    return 0;
}

